# -*- coding: utf-8 -*-
"""
Created on Sun Aug 27 08:15:36 2023

@author: skunk69
"""

import json

chinese_name = u'护士用简明精神病量表'
english_name = 'The Nurse’s BPRS'
abbreviation = 'N-BPRS'
category = u'精神病学临床量表'

outline = u"""《护士用简明精神病量表》（The Nurse’s BPRS, N-BPRS）由美国NIMH的Bigelow和Murphy于1978年编制，是从BPRS发展而来，为适合护理工作的特征，进行了补充和修改，将18项的BPRS增加为26项，评定范围扩大至病房中各类精神病患者的各类行为。"""

instruction = u"""采用七级评分，从“无”、“很轻”、“轻度”、“中度”、“较重”、“重度”到“极重”。"""

with open('N-BPRS.txt','r',encoding='utf-8') as f:
    lines = f.readlines()
    f.close()

lines_items = [l.strip() for l in lines[0:26]]
lines_rating_standard = [l.strip() for l in lines[26::]]
lines_items_definition = lines_rating_standard[::7]

items = {}
for num,line in enumerate(lines_items):
    _,value = line.split('）',maxsplit=1)
    items[num+1] = value.strip()

items_definition = {}
for line in lines_items_definition:
    key,value = line.split('．',maxsplit=1)
    items_definition[key] = value

rating_standard = {}
for num,line in enumerate(lines_rating_standard[::7]):
    item = {}
    item[num+1] = items[num+1]
    rate = {}
    rate[1] = u'（1）无；'
    lines_rate = lines_rating_standard[num*7+1:(num+1)*7]
    for i in range(len(lines_rate)):
        rate[i+2] = lines_rate[i].strip()
    rating_standard[num+1] = [item,rate]

reverse_items = []
scales = []
scales_items = []
factors = []
factors_scales = []
rating = [u'无',u'很轻',u'轻度',u'中度',u'较重',u'重度',u'极重']
score_rules = list(range(1,8))

contents = {
    'instruction':instruction,
    'items':items,
    'items_definition':items_definition,
    'rating_standard':rating_standard,
    'reverse_items':reverse_items,
    'scales':scales,
    'scales_items':scales_items,
    'factors':factors,
    'factors_scales':factors_scales,
    'rating':rating,
    'score_rules':score_rules       
    }

implementation = u"""本测验是一种护士用精神病性症状严重程度的他评量表，适用于具有精神病性症状的大多数重性精神病患者，尤适宜于精神分裂症患者。
评定注意事项
（1）本量表的评定需利用一切可能的资料和信息，包括观察、记录及病室和家属的反映等。
（2）按评定期限内最严重的情况评分。
（3）需由经训练的病室护士评定。
（4）评定期限，一般为1～2周。"""

reliability = u""""""
validity = u""""""
measurements = {'reliability':reliability,'validity':validity}

interpretation = u"""主要统计指标为各单项分和总分。总分越高，病情越严重。"""

applications = u"""国内尚无本量表的应用结果报告。量表编制者认为，该量表具有较好的信度和效度，与精神科医师评定的BPRS结果具有较高一致性。用以做疗效评估，结果满意。在英国（Downing AR和Brockintong IF，1978）的应用评价认为是最佳的两种护士用量表之一。"""

this_scale = {
    'chinese_name':chinese_name,
    'english_name':english_name,
    'abbreviation':abbreviation,
    'category':category,
    'outline':outline,
    'contents':contents,
    'implementation':implementation,
    'measurements':measurements,
    'interpretation':interpretation,
    'applications':applications    
    }

with open(abbreviation+'.json','w+',encoding='utf-8') as f:
    json.dump(this_scale,f,indent=2,ensure_ascii=False)